#!/usr/bin/env python
# coding=utf-8
"""
Bunch的设计模式
值得学习
"""
class Bunch(dict):
    def __init__(self, *args, **kwds):
        super(Bunch, self).__init__(*args, **kwds)
        self.__dict__ = self

x = Bunch(name="jk", position="1234")
print x.name
print x.position

dd = {"name":["jkhere",], "age":30, "relative":{"dad":"jiangbaiyu", "mom":{"name":"xuekexiang", "age":55}}}
y = Bunch(**dd)
print y.name
print y.age
print y.relative
# 这行打印错误，仅仅支持一层
print y.relative.dad
